package com.pkx.guide.fcms.service.impl;

import com.pkx.guide.fcms.service.FcmsPlayItemService;
import com.pkx.guide.info.entity.TInfoGuidePlayItem;
import com.sansi.playlist.PlayItem;
import com.sansi.playlist.entry.PictureBase;
import com.sansi.playlist.entry.PlayTimeBase;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service("picture")
public class FcmsPicturePlayItemServiceImpl implements FcmsPlayItemService {

    /**
     * 生成播放项
     * @return
     */
    @Override
    public PlayItem generatePlayItem(TInfoGuidePlayItem tInfoGuidePlayItem, String playListName, int index){
        // 图片动画总时间
        PlayTimeBase pictPlayTime = new PlayTimeBase(tInfoGuidePlayItem.getPlayTotalTime());
        // 展示图片信息
        PictureBase pictureBase = new PictureBase(tInfoGuidePlayItem.getPictureType(), tInfoGuidePlayItem.getPictureName());
        // 设置图片播放项
        String id = UUID.randomUUID().toString().replace("-", "");
        String itemName = "ITEM" + playListName + "0" + index;
        PlayItem picturePlayItem = new PlayItem(index, id, itemName, pictureBase, pictPlayTime);
        picturePlayItem.setX(tInfoGuidePlayItem.getPlayItemX());
        picturePlayItem.setY(tInfoGuidePlayItem.getPlayItemY());
        tInfoGuidePlayItem.setPlayItemNo(index);
        tInfoGuidePlayItem.setPlayItemId(id);
        tInfoGuidePlayItem.setPlayItemName(itemName);
        return picturePlayItem;
    }
}
